package com.colorful.insuranceproject.bean;

import android.content.Context;
import android.os.Parcel;

import com.colorful.insuranceproject.R;
import com.lovely3x.loginandresgiter.bean.SimpleUser;


/**
 * Created by john on 2016/8/2.
 *
 *   个人资料
 */
public class UserInfo extends SimpleUser {


    private boolean issign;//是否签到

    private String seriesstr;//签到记录

    private String day;//今日签到信息

    /**
     * Instantiates a new User info.
     */
    public UserInfo() {
    }

    /**
     * 获取数字性别
     *
     * @param context     环境
     * @param readableSex 可读性别
     * @return
     */
    public static int getDigitSex(Context context, String readableSex) {
        int digitSex = 0;
        //（1：男 2：女）
        if (context.getString(R.string.man).equals(readableSex)) {
            digitSex = 1;
        } else if (context.getString(R.string.woman).equals(readableSex)) {
            digitSex = 2;
        }
        return digitSex;
    }

    public boolean issign() {
        return issign;
    }

    public void setIssign(boolean issign) {
        this.issign = issign;
    }

    public String getSeriesstr() {
        return seriesstr;
    }

    public void setSeriesstr(String seriesstr) {
        this.seriesstr = seriesstr;
    }

    public String getDay() {
        return day;
    }

    public void setDay(String day) {
        this.day = day;
    }

    /**
     * 获取可读的性别
     *
     * @param context  环境对象
     * @param digitSex 数字性别
     * @return
     */
    public static String getReadableSex(Context context, int digitSex) {
        return context.getString(digitSex == 1 ? R.string.man : (digitSex == 2 ? R.string.woman : R.string.other));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeByte(this.issign ? (byte) 1 : (byte) 0);
        dest.writeString(this.seriesstr);
        dest.writeString(this.day);
    }

    protected UserInfo(Parcel in) {
        super(in);
        this.issign = in.readByte() != 0;
        this.seriesstr = in.readString();
        this.day = in.readString();
    }

    public static final Creator<UserInfo> CREATOR = new Creator<UserInfo>() {
        @Override
        public UserInfo createFromParcel(Parcel source) {
            return new UserInfo(source);
        }

        @Override
        public UserInfo[] newArray(int size) {
            return new UserInfo[size];
        }
    };
}
